clear
%% function contour
d = 2;
x_bound = repmat([-5,5],[d,1]);
global o M
load('composition_data.mat','o','M_CF3_2D')
o = o(1:6,1:d);
M = M_CF3_2D;
OptSet.radius = 0.01;
OptSet.fval = 0;
OptSet.sol = o;
%%
if d==1
    x=x_bound(1,1):(x_bound(1,2)-x_bound(1,1))/1000:x_bound(1,2);
    z=ObjValue(x');
    %%
    figure()
    plot(x,z)
    title('Equal Minima')
    xlabel('','Interpreter','latex','String','$x$')
    ylabel('','Interpreter','latex','String','$f(x)$')
    set(gca,'Fontname','Times New Roman','FontSize',16);
end
%%
if d==2
    x=x_bound(1,1):(x_bound(1,2)-x_bound(1,1))/1000:x_bound(1,2);
    y=x_bound(2,1):(x_bound(2,2)-x_bound(2,1))/1000:x_bound(2,2);
    z=zeros(length(y), length(x));
    for i=1:length(x)
        for j=1:length(y)
            z(j,i)=ObjValue([x(i),y(j)]);
        end
    end
    %%
    figure()
    mesh(x,y,z)
    colormap jet
    colorbar
    title('Composition function 3')
    xlabel('','Interpreter','latex','String','$x_1$')
    ylabel('','Interpreter','latex','String','$x_2$')
    zlabel('','Interpreter','latex','String','$f(x)$')
    set(gca,'Fontname','Times New Roman','FontSize',16);
end

